package com.yalemang.widget.tableview

import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.widget.TextView

abstract class TableTextAdapter: TableAdapter() {
    override fun createXView(parent: ViewGroup, position: Int): View {
        val textView = TextView(parent.context)
        textView.gravity = Gravity.CENTER
        return textView
    }

    override fun createYView(parent: ViewGroup, position: Int): View {
        val textView = TextView(parent.context)
        textView.gravity = Gravity.CENTER
        return textView
    }

    override fun createContentView(parent: ViewGroup, xPosition: Int, yPosition: Int): View {
        val textView = TextView(parent.context)
        textView.gravity = Gravity.CENTER
        return textView
    }

    override fun createXYView(parent: ViewGroup) : View {
        val textView = TextView(parent.context)
        textView.gravity = Gravity.CENTER
        return textView
    }

    open fun notifyDataSetChanged() {
        tableView.notifyDataSetChanged()
    }

    override fun showXY(view: View) {
        showXY(view as TextView)
    }

    override fun showX(view: View, position: Int) {
        showX(view as TextView, position)
    }

    override fun showContent(view: View, xPosition: Int, yPosition: Int) {
        showContent(view as TextView, xPosition, yPosition)
    }

    override fun showY(view: View, position: Int) {
        showY(view as TextView, position)
    }

    // 显示XY交界处内容
    open fun showXY(textView: TextView) {

    }
    // 显示X轴文本内容
    abstract fun showX(textView: TextView, position : Int)
    // 显示Y轴文本内容
    abstract fun showY(textView: TextView, position: Int)
    // 显示表格内容
    abstract fun showContent(textView: TextView, xPosition: Int, yPosition:Int)
}